package com.zg.common.core.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;

/**
 * <p>Description: </p>
 *
 * @author zhanfeng.liang
 * @since 2025/5/22 10:23
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class SystemException   extends RuntimeException implements Serializable {

    private static final long serialVersionUID = 1L;

    private Integer code;
    private String msg;

    public SystemException(IException e) {
        this.code = e.getCode();
        this.msg = e.getMsg();
    }

    public SystemException(IException e, String suffix) {
        this.code = e.getCode();
        this.msg = suffix + e.getMsg();
    }

    public SystemException(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static void happen(Integer code, String msg) {
        throw new SystemException(code, msg);
    }

    public static void happen(String msg) {
        throw new SystemException(-1, msg);
    }
}
